package com.shuqi.model;

import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import android.content.Context;

import com.shuqi.common.MyTask;
import com.shuqi.common.Urls;
import com.shuqi.model.net.HttpRequest;
import com.shuqi.model.net.UrlManager;
import com.shuqi.model.net.listener.HttpRequestListener;
import com.shuqi.model.parse.parser.UserSettingParser;

/**
 * 获取软件版本信息model
 * 
 * @author linyuren
 * 
 */
public class UserSettingModel extends ModelBase implements HttpRequestListener {

    private HttpRequest httpRequest;
    private Context context;

    public UserSettingModel(Context context) {
        this.context = context;
    }

    @Override
    public void action(int actionCode, Object object) {
        fireEvent(actionCode, object);
    }

    @Override
    public List<BasicNameValuePair> setParams() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getRequestUrl() {
        return Urls.getAppUpdateUrl();
    }

    @Override
    public void onDestroy() {
        if (httpRequest != null) {
            httpRequest.abort();
        }
    }

    @Override
    public void loadData(Object... objs) {
        this.httpRequest =
                new HttpRequest(context, UrlManager.COLUMN_DOMAIN_APPINFO, getRequestUrl(), null,
                        this);
        this.httpRequest.setDataParseAdapter(new UserSettingParser());
        MyTask.runInBackground(httpRequest, true);
    }

}
